/**
 * Created by Baggio on 2018-4-25.
 */
$(function () {
    $("#submit").click(function () {
        var postData=$('#form-member-add').serialize();
        $("#form-member-add").ajaxSubmit({
            cache: true,
            type: 'POST',
            data: postData,
            url: '/admin/media/modifyAlbum.html',
            async: false,
            success: function (res) {
                var data=JSON.parse(res); //将JSON对象转化为JSON字符
                console.log(data);
                if(data.code!=1){
                    layer.msg(data.msg, {icon: 5, time: 1000});
                    return;
                }
                alert("添加成功!");
            }
        })
    });
});

function deleteAlbum(tid) {
    layer.confirm('是否删除？', {
        btn: ['是的', '还是算了吧'] //按钮
    }, function () {
        var postData = {albumId: tid};
        $.ajax({
            type: 'POST',
            url: '/admin/media/deleteAlbum.html',
            data: postData,
            dataType: 'json',
            success: function (data) {
                if (data.code != 1) {
                    layer.msg('操作失败!', {icon: 5, time: 1000});
                    console.log(data.msg);
                    return;
                }
                layer.msg('操作成功!', {icon: 6, time: 1000}, function () {
                    window.location.reload();
                })
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                //alert(XMLHttpRequest.status);
                window.location.reload();
            }
        });

    }, function () {
        return;
    });
}
